package com.itheima.d6_object_stream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.ObjectInputStream;
import java.util.ArrayList;

/*
  目标：掌握对象字节输入流的使用：反序列化对象。
 */
public class Test2ObjectInputStream {
    public static void main(String[] args) throws Exception {
        FileInputStream fis = new FileInputStream("object.txt");
        ObjectInputStream ois = new ObjectInputStream(fis);

        /*Student o = (Student) ois.readObject();

        System.out.println(o.getNama() + ":" + o.getSex());*/
        ArrayList<Student> list = (ArrayList<Student>) ois.readObject();
        list.forEach(s -> System.out.println(s.getNama() + ":" + s.getSex()));

        ois.close();
    }

}
